<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的行程</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
        }
        .header {
            background-color: #4285F4;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        .header h1 {
            margin: 0;
            font-size: 20px;
        }
        .container {
            max-width: 1200px;
            margin: 20px auto;
            padding: 0 15px;
        }
        .trip-card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            margin-bottom: 20px;
            overflow: hidden;
        }
        .trip-header {
            background-color: #f8f9fa;
            padding: 15px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .trip-title {
            font-size: 18px;
            font-weight: bold;
            color: #333;
        }
        .trip-date {
            color: #666;
            font-size: 14px;
        }
        .trip-content {
            padding: 15px;
        }
        .trip-detail {
            display: flex;
            margin-bottom: 10px;
        }
        .detail-label {
            width: 80px;
            color: #666;
            font-size: 14px;
        }
        .detail-value {
            flex: 1;
            font-size: 14px;
        }
        .trip-actions {
            padding: 10px 15px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
        }
        .btn {
            padding: 8px 15px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            font-size: 14px;
            margin-left: 10px;
        }
        .btn-primary {
            background-color: #4285F4;
            color: white;
        }
        .btn-danger {
            background-color: #dc3545;
            color: white;
        }
        .empty-trip {
            text-align: center;
            padding: 50px 0;
            color: #666;
        }
        .loading {
            text-align: center;
            padding: 30px 0;
            color: #666;
        }
        .nav {
            background-color: white;
            position: fixed;
            bottom: 0;
            width: 100%;
            display: flex;
            justify-content: space-around;
            padding: 10px 0;
            box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
        }
        .nav-item {
            text-align: center;
            color: #666;
            text-decoration: none;
            font-size: 12px;
        }
        .nav-item.active {
            color: #4285F4;
        }
        .nav-icon {
            font-size: 20px;
            display: block;
            margin-bottom: 5px;
        }
    </style>
</head>
<body>
<div class="header">
    <h1>我的行程</h1>
    <div id="user-info"></div>
</div>

<div class="container">
    <div id="trip-list">
        <div class="loading">加载中...</div>
    </div>
</div>



<script>
    // 获取用户信息
    function loadUserInfo() {
        const user = JSON.parse(localStorage.getItem('user'));
        if (user) {
            document.getElementById('user-info').textContent = user.username;
        }
    }

    // 加载行程数据
    function loadTrips() {
        // 模拟API请求
        setTimeout(() => {
            const trips = [
                {
                    id: 1,
                    title: "北京三日游",
                    date: "2023-10-01 至 2023-10-03",
                    destination: "北京",
                    budget: "5000元",
                    people: "2人",
                    notes: "参观故宫、长城等著名景点"
                },
                {
                    id: 2,
                    title: "上海商务出差",
                    date: "2023-11-15 至 2023-11-17",
                    destination: "上海",
                    budget: "3000元",
                    people: "1人",
                    notes: "参加行业会议"
                }
            ];

            displayTrips(trips);
        }, 1000);
    }

    // 显示行程列表
    function displayTrips(trips) {
        const tripList = document.getElementById('trip-list');

        if (trips.length === 0) {
            tripList.innerHTML = `
                    <div class="empty-trip">
                        <p>暂无行程记录</p>
                        <button class="btn btn-primary" onclick="location.href='/create-trip.html'">创建新行程</button>
                    </div>
                `;
            return;
        }

        let html = '';
        trips.forEach(trip => {
            html += `
                    <div class="trip-card">
                        <div class="trip-header">
                            <div class="trip-title">${trip.title}</div>
                            <div class="trip-date">${trip.date}</div>
                        </div>
                        <div class="trip-content">
                            <div class="trip-detail">
                                <div class="detail-label">目的地：</div>
                                <div class="detail-value">${trip.destination}</div>
                            </div>
                            <div class="trip-detail">
                                <div class="detail-label">预算：</div>
                                <div class="detail-value">${trip.budget}</div>
                            </div>
                            <div class="trip-detail">
                                <div class="detail-label">人数：</div>
                                <div class="detail-value">${trip.people}</div>
                            </div>
                            <div class="trip-detail">
                                <div class="detail-label">备注：</div>
                                <div class="detail-value">${trip.notes}</div>
                            </div>
                        </div>
                        <div class="trip-actions">
                            <button class="btn btn-primary" onclick="viewTrip(${trip.id})">查看详情</button>
                            <button class="btn btn-danger" onclick="deleteTrip(${trip.id})">删除</button>
                        </div>
                    </div>
                `;
        });

        tripList.innerHTML = html;
    }

    // 查看行程详情
    function viewTrip(tripId) {
        alert(`查看行程ID: ${tripId}`);
        // location.href = `/trip-detail.html?id=${tripId}`;
    }

    // 删除行程
    function deleteTrip(tripId) {
        if (confirm('确定要删除这条行程吗？')) {
            alert(`删除行程ID: ${tripId}`);
            // 这里应该调用API删除行程，然后重新加载列表
        }
    }

    // 页面加载时执行
    document.addEventListener('DOMContentLoaded', function() {
        loadUserInfo();
        loadTrips();
    });
</script>
</body>
</html>